os_socketaddr
This crate provides a type that can act as a platform-native socket address
(i.e. libc::sockaddr
)
Motivation
The std crate provides SocketAddr
for managing socket addresses. However there is no easy way to
convert SocketAddr
from/into a libc::sockaddr
because SocketAddr
has a different internal
layout.
This crate provides OsSocketAddr
which holds a libc::sockaddr
(containing an IPv4 or IPv6
address) and the conversion functions:
- from/into
SocketAddr
- from
(*const sockaddr, socklen_t)
- into
(*mut sockaddr, *mut socklen_t)
Supported targets #[cfg(target_os="xxxxxx")]
linux
, macos
and windows
are officially supported and
actively tested.
android
, dragonfly
, emscripten
, freebsd
, fuchsia
, haiku
, hermit
, illumos
, ios
,
l4re
, netbsd
, openbsd
, redox
, solaris
, vxworks
and watchos
should work but are not
tested.
Example
extern crate libc;
extern crate os_socketaddr;
use SocketAddr;
use ;
use OsSocketAddr;